//
//  PingLunContentViewController.m
//  ShangChengMoBan
//
//  Created by yaoqi yaoqi on 16/9/2.
//  Copyright © 2016年 ping. All rights reserved.
//

#import "PingLunContentViewController.h"
#import "PingLunTableViewCell.h"
@interface PingLunContentViewController ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation PingLunContentViewController
{
    int _page;
    RWScrollView * _table;
    NSMutableArray * _arr;
}
-(void)headWithRequset{
    [_table headerBeginRefreshing];
}
-(void)headRefresh{
    _page = 1;
    [self qingQiu:1];
}
-(void)footerRefresh{
    _page ++;
    [self qingQiu:0];
}
-(void)qingQiu:(int)first{
    switch (_num) {
        case 0:
            [self requestData:nil :first];
            break;
        case 1:
            [self requestData:@0 :first];
            break;
        case 2:
            [self requestData:@1 :first];
            break;
        case 3:
            [self requestData:@2 :first];
            break;
        default:
            break;
    }
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    _page = 1;
    _table = [[RWScrollView alloc ]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight-104)];
    _table.delegate = self;
    _table.dataSource = self;
    [_table addHeaderWithTarget:self action:@selector(headRefresh)];
    [_table addFooterWithTarget:self action:@selector(footerRefresh)];
    [_table registerClass:[PingLunTableViewCell class] forCellReuseIdentifier:@"cell"];
     _table.separatorStyle = UITableViewCellSelectionStyleNone;
    [self.view addSubview:_table];
   //  [TCUtils showLoadingWithView:self.view];
}
#pragma mark 评论 row
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _arr.count;
}
#pragma mark 评论 row高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    PingLunTableViewCell * cell =[[PingLunTableViewCell alloc]init];
    cell.dic = _arr[indexPath.row];

    return cell.cellHeight ;

}
#pragma mark 评论cell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    PingLunTableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:@"cell"];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
     cell.dic = _arr[indexPath.row];
    return cell;
}
#pragma mark 加载页面
-(void)requestData:(NSNumber *)shippingStatus :(int)page{
   _arr = [[NSMutableArray alloc]init];
    switch (_num) {
         case 0://全部评论网络请求
        {
//            NSMutableDictionary * dic =[ [NSMutableDictionary alloc]init];
//            [dic setObject:[self defaultLoadUserName] forKey:@"userName"];
//            [dic setObject:@"10" forKey:@"pageSize"];
//            [dic setObject:[NSString stringWithFormat:@"%d",_page] forKey:@"pageNum"];
//            if (shippingStatus != nil) {
//                [dic setObject:shippingStatus forKey:@"orderStatus"];
//            }
//
//            [NetWorking NEWjieKouQingQiu:@"全部评论" ANDIP:IP And:dic anBlock:^(NSDictionary *dic, NSError *error) {
//                  [TCUtils hiddonLoadingWithView:self.view];
//                if (!error) {
//                    if ([dic[Code] intValue] == 200) {
//                        if(page == 1  ){
//                            _arr = [[NSMutableArray alloc]init];
//                        }
//                        [_arr addObjectsFromArray:dic[Response]];
//                         [_table reloadData];//刷新tableView
//                         self.title = [NSString stringWithFormat:@"晒图(%li)",(unsigned long)_arr.count];
//                    }
//                }
//            }];
            
            
             NSArray * b = @[@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"http://file.youboy.com/a/89/92/88/7/11345737.jpg"];
            NSArray * a = @[@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"http://file.youboy.com/a/89/92/88/7/11345737.jpg",@"http://file.youboy.com/a/143/81/34/9/262759.jpg",@"http://img.pconline.com.cn/images/upload/upc/tx/wallpaper/1506/08/c0/8174552_1433772926687_800x600.jpg"];
            [_arr addObjectsFromArray:@[@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪",@"xing":@"5",@"content":@"都是进口的速度速度,是多少,的时代结束了倒计时的,是,但是当时的就是动漫女生,代码女神,大美女速度是多少,都没事的数量的上的美食,.的美食零食",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽",@"image":a},@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪dasd",@"xing":@"3",@"content":@"都是进口的速度速度",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽",@"image":b},@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪",@"xing":@"4",@"content":@"都是进口的速度速度,是多少,的时代结束了倒计时的,是,但是当时的就是动漫女生,代码女神,大美女速度是多少,都没事的数量的上的美食,.的美食零食",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽"},@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪",@"xing":@"4",@"content":@"都是进口的速度速度,是多少,的时代结束了倒计时的,是,但是当时的就是动漫女生,代码女神,大美女速度是多少,都没事的数量的上的美食,.的美食零食",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽",@"image":b},@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪dasd",@"1":@"xing",@"content":@"都是进口的速度速度",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽",@"image":a},@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪",@"xing":@"3",@"content":@"都是进口的速度速度,是多少,的时代结束了倒计时的,是,但是当时的就是动漫女生,代码女神,大美女速度是多少,都没事的数量的上的美食,.的美食零食",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽"},@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪",@"xing":@"5",@"content":@"都是进口的速度速度,是多少,的时代结束了倒计时的,是,但是当时的就是动漫女生,代码女神,大美女速度是多少,都没事的数量的上的美食,.的美食零食",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽",@"image":b},@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪dasd",@"xing":@"2",@"content":@"都是进口的速度速度",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽",@"image":a},@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪",@"xing":@"4",@"content":@"都是进口的速度速度,是多少,的时代结束了倒计时的,是,但是当时的就是动漫女生,代码女神,大美女速度是多少,都没事的数量的上的美食,.的美食零食",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽"}]];
            
            self.title = [NSString stringWithFormat:@"全部(%li)",(unsigned long)_arr.count];
        }break;
        case 1://晒图评论数据源
        {
            [NetWorking NEWjieKouQingQiu:@"晒图评论" ANDIP:IP And:@{@"tag":@2} anBlock:^(NSDictionary *dic, NSError *error) {
                if (!error) {
                    if ([dic[Code] intValue] == 200) {
                        [_arr addObjectsFromArray:dic[Response]];
                    }
                }
            }];
            NSArray * a = @[@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"http://file.youboy.com/a/89/92/88/7/11345737.jpg",@"http://file.youboy.com/a/143/81/34/9/262759.jpg",@"http://img.pconline.com.cn/images/upload/upc/tx/wallpaper/1506/08/c0/8174552_1433772926687_800x600.jpg"];
            NSArray * b = @[@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"http://file.youboy.com/a/89/92/88/7/11345737.jpg"];
            [_arr addObjectsFromArray:@[@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪",@"xing":@"4",@"content":@"都是进口的速度速度,是多少,的时代结束了倒计时的,是,但是当时的就是动漫女生,代码女神,大美女速度是多少,都没事的数量的上的美食,.的美食零食",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽",@"image":b},@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪dasd",@"xing":@"1",@"content":@"都是进口的速度速度",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽",@"image":a},@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪",@"xing":@"3",@"content":@"都是进口的速度速度,是多少,的时代结束了倒计时的,是,但是当时的就是动漫女生,代码女神,大美女速度是多少,都没事的数量的上的美食,.的美食零食",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽"}]];
              self.title = [NSString stringWithFormat:@"晒图(%li)",(unsigned long)_arr.count];
        }break;
        case 2://低分评论数据源
        {
            [NetWorking NEWjieKouQingQiu:@"低分评论" ANDIP:IP And:@{@"tag":@3} anBlock:^(NSDictionary *dic, NSError *error) {
                if (!error) {
                    if ([dic[Code] intValue] == 200) {
                        [_arr addObjectsFromArray:dic[Response]];
                    }
                }
            }];
             NSArray * b = @[@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"http://file.youboy.com/a/89/92/88/7/11345737.jpg"];
            NSArray * a = @[@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"http://file.youboy.com/a/89/92/88/7/11345737.jpg",@"http://file.youboy.com/a/143/81/34/9/262759.jpg",@"http://img.pconline.com.cn/images/upload/upc/tx/wallpaper/1506/08/c0/8174552_1433772926687_800x600.jpg"];
            [_arr addObjectsFromArray:@[@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪",@"xing":@"5",@"content":@"都是进口的速度速度,是多少,的时代结束了倒计时的,是,但是当时的就是动漫女生,代码女神,大美女速度是多少,都没事的数量的上的美食,.的美食零食",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽",@"image":b},@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪dasd",@"xing":@"2",@"content":@"都是进口的速度速度",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽",@"image":a},@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪",@"xing":@"4",@"content":@"都是进口的速度速度,是多少,的时代结束了倒计时的,是,但是当时的就是动漫女生,代码女神,大美女速度是多少,都没事的数量的上的美食,.的美食零食",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽"}]];
             self.title = [NSString stringWithFormat:@"低分(%li)",(unsigned long)_arr.count];
        }break;

        default://最新评论数据源
        {
            [NetWorking NEWjieKouQingQiu:@"最新评论" ANDIP:IP And:@{@"tag":@4} anBlock:^(NSDictionary *dic, NSError *error) {
                if (!error) {
                    if ([dic[Code] intValue] == 200) {
                        [_arr addObjectsFromArray:dic[Response]];
                    }
                }
            }];
             NSArray * b = @[@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"http://file.youboy.com/a/89/92/88/7/11345737.jpg"];
            NSArray * a = @[@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"http://file.youboy.com/a/89/92/88/7/11345737.jpg",@"http://file.youboy.com/a/143/81/34/9/262759.jpg",@"http://img.pconline.com.cn/images/upload/upc/tx/wallpaper/1506/08/c0/8174552_1433772926687_800x600.jpg"];
            [_arr addObjectsFromArray:@[@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪",@"xing":@"4",@"content":@"时代结束了倒计时的,是,但是当时的就是动漫女生,代码女神,大美女速度是多少,都没事的数量的上的美食,.的美食零食",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽",@"image":a},@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪dasd",@"xing":@"5",@"content":@"都是进口的速度速度",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽",@"image":b},@{@"headerImage":@"http://s12.mogujie.cn/b7/pic/120516/8u80_kqyu652wozbf6wsugfjeg5sckzsew_3264x2176.jpg",@"name":@"姚琪",@"xing":@"5",@"content":@"都是进口的速度速度,是多少,的时代结束了倒计时的,是,但是当时的就是动漫女生,代码女神,大美女速度是多少,都没事的数量的上的美食,.的美食零食",@"date":@"2016-09-02",@"color":@"颜色分类:佳佳兔[深蓝色]+浴帽",@"image":a}]];
             self.title = [NSString stringWithFormat:@"最新(%li)",(unsigned long)_arr.count];
        }
            break;
    }
    [_table reloadData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
